﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Media.Animation;
using CttAdministracion.Modelo;
using CttAdministracion.Controlador;
using CttAdministracion.vistas;
namespace CttAdministracion.Vistas
{
    /// <summary>
    /// Interaction logic for PageLogin.xaml
    /// </summary>
    public partial class PageLogin : Page
    {
        public PageLogin()
        {
            InitializeComponent();
        }

        private void Page_Loaded_1(object sender, RoutedEventArgs e)
        {
            lblError.Visibility = System.Windows.Visibility.Hidden;
            eclError.Visibility = System.Windows.Visibility.Hidden;

        }

        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            usuarios usr = new usuarios();
            usr.email = this.txtLogin.Text;
            usr.password = this.txtPassword.Password;
            LoginControler log = new LoginControler();
            usr=log.UsuarioLogin(usr);
            if (usr!=null)
            {
                PageMenu pagmenu = new PageMenu(usr);
                this.NavigationService.Navigate(pagmenu);
            }
            else
            {
                lblError.Visibility = System.Windows.Visibility.Visible;
                eclError.Visibility = System.Windows.Visibility.Visible;
            }
        }

        
    }
}
